using MbUnit.Framework;
using Quiki.ExpressionParsers;

namespace Quiki.Tests.ParsingTests
{
    public class WikiParsingTestsBase
    {
        [SetUp]
        protected virtual void Setup()
        {
            parser = new WikiTextParser();
        }

        protected WikiTextElement RootElement
        {
            get { return rootElement; }
        }

        protected void Parse(string wikiText)
        {
            rootElement = parser.Parse(wikiText);
        }

        protected void AssertElementsCount(int expectedCount)
        {
            Assert.AreEqual(expectedCount, rootElement.ChildElements.Count);
        }

        protected static void AssertElementIs(
            WikiTextElement boldElement, 
            WikiTextElementType expectedType, 
            string expectedText)
        {
            Assert.AreEqual(expectedType, boldElement.ElementType);
            Assert.AreEqual(expectedText, boldElement.Text);
        }

        protected static void AssertElementIs (
            WikiTextElement boldElement,
            WikiTextElementType expectedType)
        {
            Assert.AreEqual (expectedType, boldElement.ElementType);
        }

        protected static void AssertElementIs (
            WikiTextElement boldElement,
            WikiTextElementType expectedType,
            int expectedLevel)
        {
            Assert.AreEqual (expectedType, boldElement.ElementType);
            Assert.AreEqual (expectedLevel, boldElement.Level);
        }

        protected static void AssertElementIs (
            WikiTextElement boldElement,
            WikiTextElementType expectedType,
            int expectedLevel,
            string expectedText)
        {
            Assert.AreEqual (expectedType, boldElement.ElementType);
            Assert.AreEqual (expectedLevel, boldElement.Level);
            Assert.AreEqual (expectedText, boldElement.Text);
        }

        private WikiTextParser parser;
        private WikiTextElement rootElement;
    }
}